package com.alan.camunda.boot.delegate;

import com.alibaba.fastjson2.JSON;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * ！！！ 系统任务执行这个代理类会发生死循环
 */
@Slf4j
@Component("suspendDelegate")
public class SuspendDelegate implements JavaDelegate {
    @Resource
    private RuntimeService runtimeService;

    @Override
    public void execute(DelegateExecution execution) throws Exception {
        // 运行了会死循环
        log.info("暂停流程实例");
        runtimeService.suspendProcessInstanceById(execution.getProcessInstanceId());
    }


}
